import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '传感器名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '传感器编号',
    align:"center",
    dataIndex: 'no'
   },
 /*  {
    title: '通信状态',
    align:"center",
    dataIndex: 'communicationStatus'
   },*/
   {
    title: '通信时间',
    align:"center",
    dataIndex: 'communicationTime'
   },
   {
    title: '温度',
    align:"center",
    dataIndex: 'temperature'
   },
  {
    title: '电池电压',
    align:"center",
    dataIndex: 'voltage'
  },
   {
    title: '局放强度',
    align:"center",
    dataIndex: 'pdStrength'
   },
   {
    title: '设备类型',
    align:"center",
    dataIndex: 'type_dictText'
   },
   {
    title: '所属数据终端',
    align:"center",
    dataIndex: 'terminalId_dictText'
   },
  {
    title: '接头点',
    align:"center",
    dataIndex: 'cableJointId_dictText'
  },
  {
    title: '组织编号',
    align:"center",
    dataIndex: 'sysOrgCode'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "接头点",
    field: 'cableJointId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yc_cable_joint,name,id,sys_org_code like '"+ useUserStore().getUserInfo.orgCode+"%'"
    },
  },
  {
    label: "所属数据终端",
    field: 'terminalId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"terminal,name,id,sys_org_code like '"+ useUserStore().getUserInfo.orgCode+"%'"
    },
    //colProps: {span: 6},
  },
	{
      label: "设备名称",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "设备编号",
      field: 'no',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '设备名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入设备名称!'},
                 { pattern: /^.{6,16}$/, message: '请输入6到16位任意字符!'},
          ];
     },
  },
  {
    label: '设备编号',
    field: 'no',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 {required: true, message: '请输入4位编号!',pattern: /^[0-9A-Za-z]{4}$/},
          ];
     },
  },
  {
    label: '设备类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"device_type"
    },
  },
  {
    label: '所属数据终端编号',
    field: 'terminalId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"terminal,name,id,sys_org_code = '"+ useUserStore().getUserInfo.orgCode+"'"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属数据终端编号!'},
          ];
     },
  },
  {
    label: '所属接头',
    field: 'cableJointId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yc_cable_joint,name,id,sys_org_code = '"+ useUserStore().getUserInfo.orgCode+"'"
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
